const router = require('koa-router')()

router.get('/', async (ctx, next) => {
  await ctx.render('index', {
    title: 'Hello Koa 2!'
  })
})

//用户模块
const users = require('./users')
router.use('/user',users.routes(),users.allowedMethods())

// 商品模块
const goods = require('./goods')
router.use('/goods',goods.routes(), goods.allowedMethods())

// 订单模块
const order = require('./order')
router.use('/order',order.routes(), order.allowedMethods())

// 类目模块
const classify = require('./classify')
router.use('/classify',classify.routes(), classify.allowedMethods())


router.get('/string', async (ctx, next) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
})

module.exports = router
